package cn.com.cennavi.bean;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 滴滴标准答案
 * @ClassName: DiDistatardAnswer
 * @Description: TODO（这里用一句话描述这个类的作用）
 * @author bull
 * @date 2016年7月18日 下午4:28:39
 *
 */
public class DiDiStatardAnswer implements Serializable{
	public static SimpleDateFormat sf=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	/**
	 * 记录id
	 */
	public String recordNumber;
	/**
	 * 年月日2016/6/21
	 */
	public String date;
	/**
	 * 时分秒7:43:50
	 */
	public String time;
	/**
	 * 纬度
	 */
	public double lat;
	/**
	 * 经度
	 */
	public double lon;
	/**
	 * 速度 kmph
	 */
	public double speed;
	/**
	 * 海拔高度 米
	 */
	public int Altitude;
	public static DiDiStatardAnswer parseData(String line){
		String []arr=line.split(",");
		if(arr.length!=7){
			return null;
		}
		DiDiStatardAnswer didi=new DiDiStatardAnswer();
		didi.recordNumber=arr[0];
		didi.date=arr[1];
		didi.time=arr[2];
		didi.lat=Double.parseDouble(arr[3].replace("N", ""));
		didi.lon=Double.parseDouble(arr[4].replace("E", ""));
		didi.speed=Double.parseDouble(arr[5]);
		didi.Altitude=Integer.parseInt(arr[6]);
		return didi;
	}
	public long getTimeStamp() throws ParseException {
		// TODO Auto-generated method stub
		String timestamp=this.date+" "+this.time;
		long time=sf.parse(timestamp).getTime();
		return time;
	}
	public String toSting() {
		// TODO Auto-generated method stub
		StringBuffer sb = new StringBuffer();
		sb.append(this.recordNumber);
		sb.append(",");
		sb.append(this.date);
		sb.append(",");
		sb.append(this.time);
		sb.append(",");
		sb.append(this.lat);
		sb.append(",");
		sb.append(this.lon);
		sb.append(",");
		sb.append(this.speed);
		sb.append(",");
		sb.append(this.Altitude);
		return sb.toString();
	}
}
